package com.lh.controller;

import com.lh.aop.MyAspect;
import com.lh.model.Pojo;
import com.lh.service.MyAopService;
import com.lh.util.MyLog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @Author LuoHang
 * @Date 2022-05-13 13:19
 **/
@Controller
@RequestMapping("/aop")
public class MyAopController {
    @Resource(name = "myAopServiceImpl")
    private MyAopService myAopService;

    @GetMapping("/testAop")
    public @ResponseBody Pojo testAop(Integer id){
        MyLog.info(MyAopController.class, "前端传送的值：id=" + id);
        Pojo pojo = myAopService.getPojo();
        pojo.setId(id);
        MyLog.info(MyAopController.class, "Pojo=" + pojo);
        return pojo;
    }

    @GetMapping("/testAop2")
    public String testAop2(){
        return "index";
    }
}
